<?php
//dezend by http://www.yunlu99.com/ QQ:270656184
defined('BASEPATH') || exit('No direct script access allowed');
$this->load->helper('url');
?><link rel="stylesheet" type="text/css" href="/static/css/upload.css">
<form id="ff" method="post" style="margin:10px 0px 0px 10px;display:block;">
	<input type="hidden" name="id" value="<?php echo $id;?>">
	<table style="font-size:12px;" cellspacing="5">
		<tr>
			<td>链接地址</td>
			<td><input type="text" class="easyui-validatebox" name="url" value="<?php echo $url;?>"></td>
		</tr>
		<tr>
			<td>排序</td>
			<td><input type="text" class="easyui-validatebox" name="sort" value="<?php echo $sort;?>" required="true"></td>
		</tr>
		<tr>
			<td>是否交易</td>
			<td>
				<input type="radio" class="easyui-validatebox" name="status" value="0" 
<?php
if ($status == 0) {
?>checked<?php
}

?>> 否
				<input type="radio" class="easyui-validatebox" name="status" value="1" 
<?php
if ($status == 1) {
?>checked<?php
}

?>> 是
			</td>
		</tr>
		<tr>
			<td>图标</td>
			<td>
				<div id="logo_view" class="upload_view"><img src="/upload/slide/<?php echo $img;?>"></div>
				<input type="file" id="logo_upload">
				<input type="hidden" name="img" id="logo" value="<?php echo $img;?>">
			</td>
		</tr>
		<tr>
			<td></td>
			<td>
			<button type="submit" class="easyui-linkbutton" iconCls="icon-ok">提交</button>
			</td>
		</tr>
	</table>
</form>

<script language="javascript">
$(function(){
	$('#ff').form({
		url:'<?php echo site_url('slide/update');?>',
		onSubmit:function(){
			return $(this).form('validate');
		},
		success:function(data){
			data = eval('('+data+')');
			$.messager.alert('信息提示',data.msg,'info');
			if(data.error == 0){
				$('#win').window('close');
				$('#tt').datagrid('reload');
			}
		}
	});
	
	$("#logo_upload").uploadify({ 
        'swf'             : '/uploadify/uploadify.swf', 
        'uploader'        : '<?php echo site_url('slide/upload');?>', 
		'buttonClass'     : 'uploadbtn',
		'buttonText'	  : '上传图片',
		'height'          : 26,
		'width'    : 160, 
		'multi'    : false, 
		'onUploadProgress' : function(file, bytesUploaded, bytesTotal, totalBytesUploaded, totalBytesTotal) { 
            $('#progress').html('已上传'+totalBytesUploaded + ' 字节。共 ' + totalBytesTotal + ' 字节.'); 
        },
        'onUploadSuccess' : function(file, data, response) {
			data = eval('('+data+')');
			if(response && data.error == 0){
				$('#logo_view').html('<img src="/upload/slide/'+data.file_name+'">');
				$('#logo').val(data.file_name);
			}else{
				alert('上传失败');
			}
        } 
    });
});
</script>